using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using Entities;
using DAL;
using BUS;
namespace BUS
{
    public class tbDonHangBUS
    {
        public static int Insert(tbDonHang donHang)
        {
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            return donHangDAL.Insert(donHang);
        }
        public static void Update(tbDonHang donHang)
        {
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            donHangDAL.Update(donHang);
        }
        public static void Delete(int iD)
        {
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            donHangDAL.Delete(iD);
        }
        public static tbDonHangCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            return donHangDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDonHangCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            return donHangDAL.Get(cri.Criter, 0, 0, tbDonHangColumns.IdDH.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static tbDonHang GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, tbDonHangColumns.IdDH.ToString(), Condition.EQUAL, iD);
            tbDonHangDAL donHangDAL = new tbDonHangDAL();
            tbDonHangCollection donHangCollection = donHangDAL.Get(cri.Criter, 0, 0, tbDonHangColumns.IdDH.ToString(), OrderDirection.ASC.ToString(), out total);
            if (donHangCollection.Count > 0)
                return donHangCollection[0];
            return null;
        }
    }
}
